/*
 * @Author: wangc
 * @Date: 2021-03-15 15:07:03
 * @Description: 请求错误
 */
/* eslint-disable */
import { Toast } from 'vant'
import { openWin } from "@/utils/index";
Toast.setDefaultOptions({ duration: 1000 })

export const throwErr = (res, bool) => {
    let message
    if (res.code === 4000) {
        message = '无效的token，请重新登入'

        Toast({
            type: 'fail',
            message: message,
            onClose: () => {
                openWin('index')
            }
        })

    } else {
        message = res.msg || '网络请求发生错误'

        Toast({
            type: 'fail',
            message: message,
            onClose: () => {
                // openWin('yarn')
                if (bool) {
                    openWin('yarn-weaving')
                }
            }
        })
    }

    // return Promise.reject(message || '网络请求发生错误')
}